package educationaladministrationsystem.CSM.Controller.StudentAndTeacher.Teacher;

import educationaladministrationsystem.Result.Result;
import educationaladministrationsystem.CSM.Mapper.Service.StudentAndTeacher.Teacher.TeacherSupplementalGradesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("Teacher/SupplementalGrades")
public class TeacherSupplementalGradesController {
    @Autowired
    private TeacherSupplementalGradesService teacherSupplementalGradesService;

    @GetMapping("/getAllCourse")
    public Result getAllCourse(@RequestParam String UID) {
        return Result.success(teacherSupplementalGradesService.getAllCourse(UID));
    }

    @GetMapping("/getHaveSupplePeople")
    public Result getHaveSupplePeople(@RequestParam String id) {
        return Result.success(teacherSupplementalGradesService.getHaveSupplePeople(id));
    }

    @GetMapping("/getAllStudentInformationByClassId")
    public Result getAllStudentInformationByClassId(@RequestParam String id, @RequestParam int page, @RequestParam int pageNumber) {
        return Result.success(teacherSupplementalGradesService.getAllStudentInformationByClassId(id, page, pageNumber));
    }

    @PostMapping("/uploadCredit")
    public Result uploadCredit(@RequestParam String classId, @RequestParam String studentId, @RequestParam double credit, @RequestParam double classCredit) {
        teacherSupplementalGradesService.uploadCredit(classId, studentId, credit, classCredit);
        return Result.success();
    }

    @GetMapping("/getPageSum")
    public Result getPageSum(@RequestParam String id, @RequestParam int pageNumber) {
        return Result.success(teacherSupplementalGradesService.getPageSum(id, pageNumber));
    }

    @GetMapping("/getAllCourseCount")
    public Result getAllCourseCount(@RequestParam String UID) {
        return Result.success(teacherSupplementalGradesService.getAllCourseCount(UID));
    }

    @GetMapping("/haveSuppleCourseCount")
    public Result haveSuppleCourseCount(@RequestParam String UID) {
        return Result.success(teacherSupplementalGradesService.haveSuppleCourseCount(UID));
    }
}
